﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;

namespace OL.FrameCore.Infrastructure.Utility
{
    public class AutoMapperHelper
    {
        public static T2 ToMap<T1, T2>(T1 model)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap<T1, T2>());
            var mapper = config.CreateMapper();
            T2 tModel = mapper.Map<T2>(model);
            return tModel;
        }
        public static IEnumerable<T2> ToMap<T1, T2>(IEnumerable<T1> list)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap<T1, T2>());
            var mapper = config.CreateMapper();
            IEnumerable<T2> list2 = mapper.Map<IEnumerable<T2>>(list);
            return list2;
        }
    }
}
